package com.cz.datafetcher.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cz.datafetcher.entity.FetchWays;
import com.cz.datafetcher.service.FetchWaysService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/fetchways")
@Api(tags = "取数方式")
public class FetchWaysController
        extends SingleTabControllerBase<FetchWays,Integer, FetchWaysService,FetchWays>
{
    @Override
    protected QueryWrapper<FetchWays> buildQueryWrapper(FetchWays fetchWays) {
        QueryWrapper<FetchWays> qw = new QueryWrapper<>();
        qw.lambda()
                .like(StringUtils.isNotBlank(fetchWays.getName()), FetchWays::getName,fetchWays.getName())
                .like(StringUtils.isNotBlank(fetchWays.getApiClass()), FetchWays::getApiClass,fetchWays.getApiClass());
        return qw;
    }

    @Override
    protected Integer getKeyFromObj(FetchWays fetchWays) {
        return fetchWays.getId();
    }
}
